package listbyorder.access001_100.test35;

/**
 * @author code_yc
 * @version 1.0
 * @date 2020/5/30 15:31
 */
public class Solution1 {

    // 简单的二分查找， 注意细节
    public int searchInsert(int[] nums, int target) {
        int s = 0;
        int e = nums.length;
        while (s < e) {
            int mid = s + ((e - s + 1) >> 1);
            if (nums[mid] == target) {
                return mid;
            } else if (nums[mid] > target) {
                e = mid;
            } else {
                s = mid + 1;
            }
        }
        return s;
    }
}
